import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class MyEventSource {

	private Set<MyEventListener> myEventListeners = new HashSet<>();
//	List<String> listeners = new ArrayList<~>();
	public void addListener(MyEventListener listener){
		
		this.myEventListeners.add(listener);
	}
	
	public void removeListener(MyEventListener listener){
		
		this.myEventListeners.remove(listener);
	}
	
	public void pushEvent(){
		//dosomething
        //发布push event消息
		notifyListener(new MyEventObject(this, "push event"));
	}
	
	private void notifyListener(MyEventObject eventObject){
		
		for (MyEventListener myEventListener : myEventListeners) {
			myEventListener.myEvent(eventObject);
		}
	}
}